<?php
namespace app\client\controller;
class Goods extends Base {
    public function __construct() {
        parent::__construct();
    }
    
    public function store() {
        $params = request()->get();
        $page = isset($params['page']) ? intval($params['page']) : 1;
        $lastPkId = isset($params['lastPk']) ? intval($params['lastPk']) : 0;
        $pageSize = isset($params['pageSize']) ? intval($params['pageSize']) : 10;
        $goodsName = isset($params['goodsName']) ? trim($params['goodsName']) : '';
        
        $where = [['user_id', '=', $this->userid]];
        if($lastPkId > 0){
            $where[] = ['id', '<', $lastPkId];
        }
        
        if($goodsName !== ''){
            $where[] = ['goods_name', 'like', "%{$goodsName}%"];
        }
        
        
        $offset = ($page - 1) * $pageSize;
        $list = model('GoodsStore')->where($where)->field(['id', 'cover', 'goods_name', 'sale_price', 'agent_price'])->order('id desc')->limit(0, $pageSize)->select()->toArray();

        return successResult(['list' => $list]);
        
    }
}